/*
 * CloudClient.h
 *
 *  Created on: Jan 23, 2012
 *      Author: hduser
 */

#ifndef CLOUDCLIENT_H_
#define CLOUDCLIENT_H_

#include<iostream>
#include<fstream>
#include<string>
#include "hdfs.h";
#include "Connection.h";
#include "Logger.h"
#include "ExceptionHandler.h";
#include "FileUtilities.h"

using namespace std;

namespace cloud {

class CloudClient {
public:
	CloudClient(Connection* conn);
	CloudClient(char* hostname, int port_number);
	virtual ~CloudClient();
	void init();
	Connection* cloudConn;
	Logger* logger;
	int writeFileToHDFS(char* localfileName, char* hdfsfileName);
	int getFileFromHDFS(char* hdfsfileName, char* localfilename);
	int calculateNumberOfChunks(char*  hdfsfileName);
	int getChunkFromHDFS(char*  hdfsfileName, int chunkIndex, int totalChunks, char** returnBuffer);

private:
	static const int BLOCK_SIZE = 4194304; // 4MB
	static const size_t CHUNK_SIZE = 100 * BLOCK_SIZE;
};

}

#endif /* CLOUDCLIENT_H_ */
